package com.ambow.shop.service.impl;

import java.sql.SQLException;
import java.util.List;

import com.ambow.shop.dao.ProductCategoryDao;
import com.ambow.shop.dao.impl.ProductCategoryDaoJdbcImpl;
import com.ambow.shop.domain.ProductCategory;
import com.ambow.shop.service.ProductCategoryService;

/**
 * 产品类别业务模型实现。
 * 
 * @author deng.zhao
 *
 */
public class ProductCategoryServiceImpl implements ProductCategoryService {
	// 产品类别数据访问接口；
	private ProductCategoryDao productCategoryDao = new ProductCategoryDaoJdbcImpl();

	@Override
	public boolean addProductCategory(ProductCategory productCategory) {
		try {
			return productCategoryDao.add(productCategory) == 1;
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return false;
	}

	@Override
	public boolean deleteProductCategory(Integer productCategoryId) {
		try {
			return productCategoryDao.delete(productCategoryId) == 1;
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return false;
	}

	@Override
	public boolean updateProductCategory(ProductCategory productCategory) {
		try {
			return productCategoryDao.update(productCategory) == 1;
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return false;
	}

	@Override
	public ProductCategory getProductCategory(Integer productCategoryId) {
		try {
			return productCategoryDao.get(productCategoryId);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public List<ProductCategory> getProductCategories() {
		try {
			return productCategoryDao.list();
		} catch (SQLException e) {
			e.printStackTrace();
			return null;
		}

	}

}
